﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using _3Layer_CuuHangDienMay.DataAccess;
using System.Windows.Forms;

namespace _3Layer_CuuHangDienMay.BusinessLogic
{
    class ItemProduceBUS
    {
        public List<string> GetNameItemProduces()
        {
            String sql = "SELECT TENLOAISANPHAM FROM LOAISANPHAM";
            DataProvider dataProvider = new DataProvider();
            OleDbDataReader dataReader;
            List<string> listName = new List<string>();
            try
            {

                dataReader = dataProvider.ExecuteReader(sql);
                while (dataReader.Read())
                {
                    listName.Add(dataReader[0].ToString());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return null;
            }
            return listName;
        }

        public string GetCodeItemProduces(string sTenLoaiSanPham)
        {
            string sql = "SELECT MALOAISANPHAM FROM LOAISANPHAM WHERE TENLOAISANPHAM = '" + sTenLoaiSanPham + "'";
            DataProvider dataProvider = new DataProvider();
            string kq = "";
            try
            {
                kq = dataProvider.ExecuteScalar(sql);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return kq;
        }
    }
}
